﻿
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Access

''' <summary>
''' Base SVN to Access and vice versa Transformer class
''' </summary>
Public MustInherit Class AccessSvnTransformer

	Public property isCancelled as boolean
    Public Property debugLevel As enumDebugLevel = enumDebugLevel.SUMMARY

    Public Event TransformStarted()
    Public Event TransformEnd()
    Public Event TransformError(erromsg As String)

    Private _transformers As List(Of BaseAccessObjectTransformer) = Nothing
    Private _TransformerProvider As IAccessTransformerProvider

    Protected Overridable property app As Access.Application

    ''' <summary>
    ''' Holds the names of objects of this type.  This is so that we 
    ''' can keep track of objects in the access database and import 
    ''' only the objects in use.  Overtime, objects maybe renamed and 
    ''' deleted and we do not want to import these object.
    ''' </summary>
    ''' <remarks></remarks>
    Private _objectList As List(Of IExportedAccessObject)

    Private _svnClient As SVNClient

   
    Public Property ObjectList() As List(Of IExportedAccessObject)
        Get
            If Me._objectList Is Nothing Then
                Me._objectList = New List(Of IExportedAccessObject)
            End If
            Return _objectList
        End Get
        Set(ByVal value As List(Of IExportedAccessObject))
            _objectList = value
        End Set
    End Property

    Public Property SvnClient() As SVNClient
        Get
            If _svnClient Is Nothing Then
                _svnClient = New SVNClient
                _svnClient.rootSvnProjectPath = AppContext.current.RootSVNPath
            End If
            Return _svnClient
        End Get
        Set(ByVal value As SVNClient)
            _svnClient = Value
        End Set
    End Property
    Public Property TransformerProvider() As IAccessTransformerProvider
        Get
            If _TransformerProvider Is Nothing Then
                _TransformerProvider = AppContext.getTransformerProvider(AppContext.current.getAccessDatabaseFullName)
            End If
            Return _TransformerProvider
        End Get
        Set(ByVal value As IAccessTransformerProvider)
            _TransformerProvider = value
        End Set
    End Property

    Public ReadOnly Property Transformers() As List(Of BaseAccessObjectTransformer)

        Get
            If _transformers Is Nothing Then
                _transformers = Me.TransformerProvider.getTranformers
            End If
            Return _transformers
        End Get

    End Property

    Public MustOverride Sub Transform()

    Protected Sub raiseTransformStarted()
        RaiseEvent TransformStarted()
    End Sub

    Protected Sub raiseTransformEnd()
        RaiseEvent TransformEnd()
    End Sub
    Protected Sub raiseTransformError(msg As String)
        RaiseEvent TransformError(msg)
    End Sub


   
End Class
